package GUILag;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import DBLag.*;

 class MyTableCellRenderer extends DefaultTableCellRenderer {
    
    private IFDbEvent events;
    public MyTableCellRenderer() {
        events = new DbEvent();
    }
    
    @Override
    public java.awt.Component getTableCellRendererComponent(JTable table, 
                                                            Object value,
                                                            boolean isSelected,
                                                            boolean hasFocus,
                                                            int row,
                                                            int column) {
                                                                  
    
    table.setDefaultRenderer(String.class, this);
    Component celle = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (value == null){
        return celle;
    }
    //Til Adm Employee Klassen
    if((Boolean)value.equals(false))
    {
        for(int i=0; i>7; i++)
        {
            Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, i);
            celle.setBackground(Color.red);
            celle.setForeground(null);   
        }    
        celle.setBackground(Color.red);
        celle.setForeground(null);   
    }
    //Til OrderArr Klassen
    if(value.equals("Bøf & Bowl"))
    {
        celle.setBackground(Color.pink);
        celle.setForeground(null);
    }
    else if (value.equals("Børnefødselsdag"))
    {
        
        celle.setBackground(Color.red); 
        celle.setForeground(null);
    }
    else if (value.equals("Buffet nr 1"))
    {
        celle.setBackground(Color.green);
        celle.setForeground(null);
    }
    else if (value.equals("Buffet nr 2"))
    {
        celle.setBackground(Color.BLUE);
        celle.setForeground(null);
    }
    else if (value.equals("Pizza & Bowl"))
    {
        celle.setBackground(Color.YELLOW);
        celle.setForeground(null);
    }
    else if (value.equals("Dansk Middag nr 1") || value.equals("Dansk Middag nr 2"))
    {
        celle.setBackground(Color.MAGENTA);
        celle.setForeground(null);
    }  
    else if (value.equals("testEvent"))
    {
        celle.setBackground(Color.orange);
        celle.setForeground(null);
    }      
    else{
        celle.setBackground(null);
        celle.setForeground(null);
    }
    return celle;
    }
 

}